<?php
session_start() ;
if(!isset($_SESSION["login"]) || $_SESSION["login"] == "")
{   
  header("Location: index.php?error=4") ;
}?>

<html>
<head>
<title>Administration</title>
 <link rel="stylesheet" type="text/css" href="style.css" >  
</head>

<body>
<?php require("menu.php");
require("fonctions.php");
$code=$_GET["error"];
$id_push=$_GET["id_push"];
?>
<br></br>

<form action="controler.php?action=run_camp" method="post" >
<input type="hidden" name="id_push" value="<?php echo $id_push;?>">
<table  width="650">
<tr>
	<td class="tab_dis_head" colspan=3>Liste des mails concern&eacute;s par la vague.</td>
</tr>
<?php 
	$sql="(select d.codesap,d.nom ,m.email from distributeurs d
join asso_dis_man on id_distrib = d.id
join managers m on id_man = m.id order by d.codesap)

union all

(select d.codesap,d.nom ,r.email from distributeurs d
join asso_dis_resp_qual on id_distrib = d.id
join respon_qual r on id_rq = r.id order by d.codesap)

union all

(select d.codesap,d.nom ,c.email from distributeurs d
join contacts c on c.id_distrib=d.id order by d.codesap
)
	";
	
	$res = mysql_query($sql);
	
	while($r = mysql_fetch_object($res)){
	?>
<tr>
	<td class="tab_dis_data"><?php echo $r->codesap;?></td><td class="tab_dis_data"><?php echo $r->nom;?></td><td class="tab_dis_data"><?php echo $r->email;?></td>
</tr>
<?php  }?>
	
<tr>
	<td colspan="2" align="center"><input type=submit value="Envoyer Email !!"></td>
</tr>

</table>

</form>

</body>

</html>
